<%@ page language="java" import="java.util.*" pageEncoding="Utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>修改当前登陆人的密码</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css"
	href="${ctx }/resources/easyui/themes/metro/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${ctx }/resources/css/icon.css">
<link rel="stylesheet" type="text/css"
	href="${ctx }/resources/css/wu.css" />
<script type="text/javascript"
	src="${ctx }/resources/easyui/jquery.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/easyui/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
	<!-- 查询条件开始 -->
	<div class="easyui-panel"
		data-options="title:'修改密码',iconCls:'icon-search'"
		style="width:100%;">
		<form id="fm" method="post" novalidate
			style="margin:0;padding:20px 50px">
			<div style="margin-bottom:10px">
				<input type="hidden" id="curOldPwd" value="${user.pwd }">
				<input
					class="easyui-passwordbox" name="oldpwd"
					labelPosition='left',labelAlign='right'
					validType="oldeq['#curOldPwd']" required="true" label="原始密码:"
					style="width:80%;">
			</div>
			<div style="margin-bottom:10px">
				<input class="easyui-passwordbox" name="newpwd" id="newpwd"
				required="true" label="原始密码:" labelPosition='left',labelAlign='right'
					style="width:80%;">
			</div>
			<div style="margin-bottom:10px">
				<input class="easyui-passwordbox" name="pwd"  labelPosition='left',labelAlign='right'
					validType="neweq['#newpwd']" required="true" label="确认密码:"
					style="width:80%;">
			</div>
			<div style="margin-bottom:10px;text-align: center;">
				<a href="javascript:void(0)" class="easyui-linkbutton"
					onclick="savePwd()" data-options="iconCls:'icon-search'">确定修改</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					onclick="javascript:$('#fm').form('clear')"
					data-options="iconCls:'icon-reload'">重置</a>
			</div>
		</form>
	</div>

	<script type="text/javascript">
		//保存
		function savePwd() {
			$.messager.progress(); // 显示进度条
			$('#fm').form('submit',{
					url : "${ctx}/user/updateUserPwd.action",//数据提交地址  user/addUser.action
					onSubmit : function() {
						var isValid = $(this).form('validate');//对表单里面的required:true和vailType的数据进行验证
						if (!isValid) {
							$.messager.progress('close'); // 如果验证失败关闭进度条
						}
						return isValid; //返回验证结果
					},
					success : function(obj) {//如果提交成功之后回调的方法
						$.messager.progress('close'); // 关闭进度条
						var result = eval('(' + obj + ')');//把obj的josn字符串转成js认识的json对象
						$.messager
								.alert({
									title : '提示',
									msg : result.msg,
									fn : function() {
										window.parent.location.href = "${ctx}/login/logOut.action";
									}
								});
					}
			});
		}
		$.extend($.fn.validatebox.defaults.rules, {
		    oldeq: {
		        validator: function(value,param){
		            return value == $(param[0]).val();
		        },
		        message: '原始密码不匹配'
		    },
		    neweq: {
		        validator: function(value,param){
		            return value == $(param[0]).val();
		        },
		        message: '两次密码不匹配'
		    }
		});
	</script>
</body>
</html>
